package com.cnxjs.shs4et.controller;

import com.cnxjs.shs4et.common.Result;
import com.cnxjs.shs4et.entity.Discussion;
import com.cnxjs.shs4et.service.DiscussionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/discussion")
public class DiscussionController {

    @Autowired
    private DiscussionService discussionService;

    // 时间顺序查一个回复下的所有讨论
    @GetMapping("/time")
    public Result findAll(@RequestParam int comment) {
        return discussionService.findAll(comment);
    }

    // 对 回复或讨论 进行讨论
    @PostMapping("/add")
    public Result add(@RequestBody Discussion discussion) {
        return discussionService.add(discussion);
    }

    // 伪删除讨论
    @DeleteMapping("/delete/{id}")
    public Result delete(@PathVariable int id) {
        return discussionService.delete(id);
    }
}
